package site.sorghum.ddl.field;

import java.sql.JDBCType;

public class MysqlTypeConvert extends BasicTypeConverter {
    public static final TypeConverter INSTANCE = new MysqlTypeConvert();

    @Override
    public String convertToDatabaseType(JDBCType jdbcType) {
        if (jdbcType == null) {
            throw new IllegalArgumentException("JDBC type cannot be null");
        }

        switch (jdbcType) {
            case BOOLEAN:
                return "TINYINT";
            case LONGVARCHAR:
                return "LONGTEXT";
            case LONGVARBINARY:
                return "LONGBLOB";
            case TIME_WITH_TIMEZONE:
            case TIMESTAMP_WITH_TIMEZONE:
                return "TIMESTAMP";
            default:
                return super.convertToDatabaseType(jdbcType);
        }
    }
}
